package api

import (
	"blizzard/app/model"
	"blizzard/app/service"
	"blizzard/app/utils/code"
	"blizzard/app/utils/response"
	"github.com/gogf/gf/net/ghttp"
)

var SignView = new(apiSignView)

type apiSignView struct {}

func (a *apiSignView) Add(r *ghttp.Request) {
	var (
		data *model.AddSignCardParam
		err error
	)
	if err = r.Parse(&data); err != nil {
		response.JsonExit(r, code.ParamError, err.Error())
	}
	if err = service.SignView.Add(r, data); err != nil {
		response.JsonExit(r, code.ServerError, err.Error())
	}
	response.Json(r, code.Success, code.SuccessMsg)
}

func (a *apiSignView) List(r *ghttp.Request) {
	var (
		list interface{}
		err error
	)
	list, err = service.SignView.List()
	if err != nil {
		response.JsonExit(r, code.ServerError, err.Error())
	}
	response.Json(r, code.Success, code.SuccessMsg, list)
}